package algo;

import java.util.HashSet;
import java.util.Set;

public class GetLargestUnique {
    public int getLargestUnique(int[] nums){
        int ans = 0;
        Set<Integer> dupSet = new HashSet<>();
        Set<Integer> uniSet = new HashSet<>();
        for (int i : nums) {
            if(!dupSet.contains(i)) {
                uniSet.add(i);
                dupSet.add(i);
            } else {
                uniSet.remove(i);
            }

        }

        for (int i:uniSet) {
            ans = Math.max(ans, i);
        }
        return ans;
    }

    public static void main(String[] args) {
        int i = new GetLargestUnique().getLargestUnique(new int[]{1,24,5,6,7,7,4,9,24});
        System.out.println(i);
        i = new GetLargestUnique().getLargestUnique(new int[]{1,24,5,6,7,7,4,9,24,24});
        System.out.println(i);
    }
}
